package org.itworks.biodev.model;

import java.sql.SQLException;
import java.util.Vector;

public class Product {
	private Integer id;
	private String label;
	private Integer realQuantity;
	private Integer logicalQuantity;
	private Float price;
	private Integer thresholdWarningQuantity;
	private Unit unit = null;
	private Integer unitQuantity;
	private VATRate vatRate;
	private Vector<ProductSpecificity> specificities;
	private ProductSubCategory subCategory;
	private int subCategoryId;
	
	public Product () {
		/* ID */
	}
	
	public Integer getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public Integer getRealQuantity() {
		return realQuantity;
	}

	public void setRealQuantity(Integer realQuantity) {
		this.realQuantity = realQuantity;
	}

	public Integer getLogicalQuantity() {
		return logicalQuantity;
	}

	public void setLogicalQuantity(Integer logicalQuantity) {
		this.logicalQuantity = logicalQuantity;
	}

	public Float getPrice() {
		return price;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	public Integer getThresholdWarningQuantity() {
		return thresholdWarningQuantity;
	}

	public void setThresholdWarningQuantity(Integer thresholdWarningQuantity) {
		this.thresholdWarningQuantity = thresholdWarningQuantity;
	}

	public Unit getUnit() {
		return unit;
	}

	public void setUnit(Unit unit) {
		this.unit = unit;
	}

	public Integer getUnitQuantity() {
		return unitQuantity;
	}

	public void setUnitQuantity(Integer unitQuantity) {
		this.unitQuantity = unitQuantity;
	}

	public VATRate getVatRate() throws Exception {
		if(this.vatRate == null) {
			this.vatRate = ProductTable.getInstance().findVatRatFromProduct(this);
		}
		return this.vatRate;
	}

	public void setVatRate(VATRate vatRate) {
		this.vatRate = vatRate;
	}

	public Vector<ProductSpecificity> getSpecificities() {
		return specificities;
	}

	public ProductSubCategory getSubCategory() throws Exception {
		if(subCategory == null) {
			subCategory = ProductTable.getInstance().findSubCategoryFromProduct(this);
		}
		return subCategory;
	}

	public void setSubCategory(ProductSubCategory subCategory) {
		this.subCategory = subCategory;
		this.subCategoryId = subCategory.getId();
	}
	
	public int getSubCategoryId() {
		return this.subCategoryId;
	}
	
	public void setSubCategoryId(int id) {
		this.subCategoryId = id;
	}
}
